package com.dwxt.community.admin.controller;

import com.dwxt.common.base.*;
import com.dwxt.community.entity.dto.*;
import com.dwxt.community.service.*;
import org.apache.commons.lang.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.validation.annotation.*;
import org.springframework.web.bind.annotation.*;

/**
 *  广播 后台管理
 * @author shenwenkang
 */
@RestController
@RequestMapping("/cms/admin/broadcast")
public class BroadcastControllerAdmin {

    @Autowired
    private BroadcastService broadcastService;



    /**
     * showdoc
     * @catalog 社区后台管理/直播
     * @title 栏目列表  or 搜索
     * @method  get
     * @description  栏目列表  or 搜索
     * @param type 非必须 String 栏目类型ID
     * @param name 非必须 String 搜索 关键词
     * @url /cms/admin/broadcast/getIncludeChild
     * @return {"status":200,"msg":"SUCCESS","data":{"total":4,"list":[{"id":"158564638123180","name":"奥特曼","priority":20,"description":"新的风暴已经出现\n怎么能够停止不前","type":"158564821672458","createTime":"2020-03-3109:19:41","updateTime":"2020-03-3109:19:41","cover":"栏目2","areaCode":"2100","use":0,"columnType":{"id":"158564821672458","name":"电视","createTime":1585677004000,"updateTime":1585677005000,"description":"电视"}}],"pageNum":1,"pageSize":10,"size":4,"startRow":1,"endRow":4,"pages":1,"prePage":0,"nextPage":0,"isFirstPage":true,"isLastPage":true,"hasPreviousPage":false,"hasNextPage":false,"navigatePages":8,"navigatepageNums":[1],"navigateFirstPage":1,"navigateLastPage":1}}
     */
    @GetMapping("/get")
    public BaseResult get(@RequestParam(defaultValue = "1") Integer pageNum,
                          @RequestParam(defaultValue = "10") Integer pageSize,
                          String type,
                          String name) {
        return broadcastService.get(pageNum, pageSize, type, name);
    }

    /**
     * showdoc
     * @catalog 社区后台管理/直播
     * @title 添加栏目
     * @method:  post
     * @description  添加栏目
     * @param id 必须 String 栏目ID
     * @param name 必须 String 栏目ID
     * @param priority 必须 Integer 栏目优先级
     * @param description 必须 String 栏目描述
     * @param type 必须 String 栏目类型ID
     * @param cover 必须 String 栏目封面图
     * @param use 必须 String 是否启用 1.启用 0.停用
     * @param id 必须 Integer 栏目ID
     * @url /cms/admin/broadcast/insert
     * @remark 需将请求设置为 application/json 格式
     * @return {"status":200,"msg":"SUCCESS","data":null}
     */
    @PostMapping("/insert")
    public BaseResult get(@RequestBody @Validated BroadcastColumnDto broadcastColumns) {
        return broadcastService.insert(broadcastColumns);
    }

    /**
     * showdoc
     * @catalog 社区后台管理/直播
     * @title 修改栏目
     * @method  post
     * @description  修改栏目
     * @param id 必须 String 栏目ID
     * @param name 必须 String 栏目ID
     * @param priority 必须 Integer 栏目优先级
     * @param description 必须 String 栏目描述
     * @param type 必须 String 栏目类型ID
     * @param cover 必须 String 栏目封面图
     * @param use 必须 String 是否启用 1.启用 0.停用
     * @param id 必须 Integer 栏目ID
     * @url /cms/admin/broadcast/update
     * @remark 需将请求头设置为 application/json 格式
     * @return {"status":200,"msg":"SUCCESS","data":null}
     */
    @PostMapping("/update")
    public BaseResult update(@RequestBody @Validated BroadcastColumnDto broadcastColumns) {
        String id = broadcastColumns.getId();
        if (StringUtils.isBlank(id)) {
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastService.update(broadcastColumns);
    }

    /**
     * showdoc
     * @catalog 社区后台管理/直播
     * @title 删除栏目
     * @method  delete
     * @description  修改栏目
     * @param id 必须 String 栏目ID
     * @url /cms/admin/broadcast/del
     * @return {"status":200,"msg":"SUCCESS","data":null}
     */
    @DeleteMapping("/del")
    public BaseResult del(String id) {
        if (StringUtils.isBlank(id)) {
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastService.del(id);
    }

    /**
     * showdoc
     * @catalog 社区后台管理/直播
     * @title 删除栏目下的某个视频
     * @method  delete
     * @description  删除栏目下某个的视频 物理删除
     * @param id 必须 String 栏目下的视频的ID
     * @url /cms/admin/broadcast/delBroadcast
     * @return {"status":200,"msg":"SUCCESS","data":null}
     */
    @DeleteMapping("/delBroadcast")
    public BaseResult delBroadcast(String id) {
        if (StringUtils.isBlank(id)) {
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastService.delBroadcast(id);
    }


    /**
     * showdoc
     * @catalog 社区后台管理/直播
     * @title 获取栏目类型
     * @method  get
     * @description  获取栏目类型
     * @url /cms/admin/broadcast/getColumeType
     * @return {"status":200,"msg":"SUCCESS","data":[{"id":"158564818887714","name":"慢直播","createTime":1585676948000,"updateTime":1585676946000,"description":"慢直播"}]}
     */
    @RequestMapping("/getColumeType")
    public BaseResult getColumeType() {
        return broadcastService.getColumeType();
    }

    /**
     * showdoc
     * @catalog 社区后台管理/直播
     * @title 停用 or 启用
     * @method  post
     * @description  停用 or 启用
     * @url /cms/admin/broadcast/useOrStop
     * @param id 必须 String 栏目ID
     * @return {"status":200,"msg":"SUCCESS","data":null}
     */
    @RequestMapping("/useOrStop")
    public BaseResult useOrStop(String id){
        if (StringUtils.isBlank(id)){
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastService.useOrStop(id);
    }

    /**
     * showdoc
     * @catalog 社区后台管理/直播
     * @title 栏目详情
     * @method  get
     * @description  栏目详情
     * @url /cms/admin/broadcast/detail
     * @param id 必须 String 栏目ID
     * @return {"status":200,"msg":"SUCCESS","data":null}
     */
    @RequestMapping("/detail")
    public BaseResult detail(String id){
        if (StringUtils.isBlank(id)){
            return BaseResult.build(StatusCode.PARAMETER_WRONG);
        }
        return broadcastService.detail(id);
    }
}
